package com.lindroy.androidplayer.viewmodels

import android.view.View
import androidx.lifecycle.ViewModel
import com.elvishew.xlog.XLog
import com.lindroy.androidplayer.logic.model.bean.TabBean
import com.lindroy.androidplayer.utils.SingleLiveEvent
import com.lindroy.androidplayer.utils.toArrayList

/**
 * @author Lin
 * @date 2022/1/24
 * @function
 */
data class KnowledgeItemViewModel(
    val id: Int,
    val name: String,
    val tabList: List<TabBean>,
    private val itemClickAction: SingleLiveEvent<List<TabBean>>
) : ViewModel() {

    fun onItemClick(view: View) {
        itemClickAction.postValue(tabList.apply { find { it.id == id }?.isSelected = true }.toArrayList())
    }
}